﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JTLeigh.Commerce.Spencer.Features.ProductImages.Common.Entities;
using JTLeigh.Commerce.Spencer.Core.Testing;

namespace JTLeigh.Commerce.Spencer.Features.ProductImages.Common.UnitTests.Entities
{

	/// <summary>
	/// Unit tests for the <see cref="LocalizedProductImageSize"/> class.
	/// </summary>
	[TestClass]
	public class LocalizedProductImageSizeFixture
	{

		#region Methods

		/// <summary>
		/// Ensures <see cref="LocalizedProductImageSize"/> returns localized values for its 
		/// localizable fields when its constructor is passed a <see cref="ProductImageSizeLocalization"/> 
		/// object.
		/// </summary>
		[TestMethod]
		public void TestLocalizedProductImageSizeOperationWithLocalization()
		{
			ProductImageSize size;
			ProductImageSizeLocalization localization;
			LocalizedProductImageSize localizedSize;

			size = new ProductImageSize
			{
				SizeId = Guid.NewGuid(),
				WellKnownSizeCode = 1,
				Width = 150,
				Height = 100,
				DisplayOrder = 2,
				DefaultName = "defaultName",
				DefaultMissingImagePath = "defaultMissingImagePath",
			};
			localization = new ProductImageSizeLocalization
			{
				SizeId = Guid.NewGuid(),
				CultureId = TestConstants.CultureId.EnglishCanada,
				Name = "localizedName",
				MissingImagePath = "localizedMissingImagePath",
			};
			localizedSize = new LocalizedProductImageSize(size, localization);

			Assert.AreEqual(size.SizeId, localizedSize.SizeId);
			Assert.AreEqual(size.WellKnownSizeCode, localizedSize.WellKnownSizeCode);
			Assert.AreEqual(size.Width, localizedSize.Width);
			Assert.AreEqual(size.Height, localizedSize.Height);
			Assert.AreEqual(size.DisplayOrder, localizedSize.DisplayOrder);
			Assert.AreEqual(localization.Name, localizedSize.Name);
			Assert.AreEqual(localization.MissingImagePath, localizedSize.MissingImagePath);
		}

		/// <summary>
		/// Ensures <see cref="LocalizedProductImageSize"/> returns default values for its 
		/// localizable fields when its constructor is passed a <see langword="null"/> value 
		/// instead of a <see cref="ProductImageSizeLocalization"/> object.
		/// </summary>
		[TestMethod]
		public void TestLocalizedProductImageSizeOperationWithoutLocalization()
		{
			ProductImageSize size;
			LocalizedProductImageSize localizedSize;

			size = new ProductImageSize
			{
				SizeId = Guid.NewGuid(),
				WellKnownSizeCode = 1,
				Width = 150,
				Height = 100,
				DisplayOrder = 2,
				DefaultName = "defaultName",
				DefaultMissingImagePath = "defaultMissingImagePath",
			};
			localizedSize = new LocalizedProductImageSize(size, null);

			Assert.AreEqual(size.SizeId, localizedSize.SizeId);
			Assert.AreEqual(size.WellKnownSizeCode, localizedSize.WellKnownSizeCode);
			Assert.AreEqual(size.Width, localizedSize.Width);
			Assert.AreEqual(size.Height, localizedSize.Height);
			Assert.AreEqual(size.DisplayOrder, localizedSize.DisplayOrder);
			Assert.AreEqual(size.DefaultName, localizedSize.Name);
			Assert.AreEqual(size.DefaultMissingImagePath, localizedSize.MissingImagePath);
		}

		#endregion // Methods

	}

}
